<template>
  <div>
      <p class="five" ref="colorP">生成随机色</p>
  </div>
</template>

<script>
export default {
  created () {
  },
  mounted () {
    this.randomColor(this.$refs.colorP)
  },
  methods: {
    randomColor (dom) {
      dom.style.backgroundColor = `rgba(${Math.floor((Math.random() * 360))}, ${Math.floor((Math.random() * 360))}, ${Math.floor((Math.random() * 360))}, ${Math.floor((Math.random() * 10)) / 10})`
    }
  }
}
</script>

<style>
.five {
   height: 40px;
   font-size: 22px;
   text-align: center;
   line-height: 40px;
   background-color: rgba(red, green, blue, alpha);
}
</style>
